<?php

/**
 * Parser for Kinopoisk rating
 */
class KinopoiskParser {

    /**
     * Parse information about rating
     * 
     * @param int $kpId     Contains ID of movie on Kinopoisk side
     * 
     * @return array
     */
    public function parseRating($kpId) {
        $result = array();
        // Get URL to simple xml object
        $rating = simplexml_load_file("http://www.kinopoisk.ru/rating/$kpId.xml");
        if ($rating) {
            $result['kp_rating'] = (string) $rating->kp_rating;
            $result['imdb_rating'] = (string) $rating->imdb_rating;
        }
        return $result;
    }

}